package com.zdhy.zoc.collect.ping;

import com.zdhy.zoc.collect.snmp.SnmpUtil;

import java.io.IOException;
import java.net.*;
import java.util.Enumeration;

/**
 * Created by 梁浩峰 on 2016/8/25 13:45.
 */
public class Pingutil {
    public static Boolean isAddressAvailable(String ip){
      Boolean status=false;
        try{
            InetAddress address = InetAddress.getByName(ip);//ping this IP
            boolean reachable = address.isReachable(5000);
            if(reachable) {
                status = true;
            }
        }catch(Exception e){
            System.out.println("error occurs.");
            e.printStackTrace();
        }
        return status;
    }


    public static void main(String[] args) throws UnknownHostException {
        isAddressAvailable("127.0.0.1");

    }
}
